package com.lanyam.travel.base.dao;

import java.util.List;

import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lanyam.travel.base.entity.TravelMenu;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author rosson
 * @since 2020-02-24
 */
public interface TravelMenuMapper extends BaseMapper<TravelMenu> {

	@Select("select max(index_num) from travel_menu where father_menu_id is null")
	String getFatherMenuMaxIndex();

	@Select("select max(index_num) from travel_menu where father_menu_id = #{fatherId}")
	String getChildMenuMaxIndex(String fatherId);

	@Select("SELECT tm.*,fm.menu_name AS fatherMenuName FROM travel_menu tm LEFT JOIN travel_menu fm ON fm.id = tm.father_menu_id")
	List<TravelMenu> selectAllMenu();
	
	List<TravelMenu> searchMenu(String name);

}
